package top.lingkang;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import top.lingkang.screen.WelcomeScreen;

public class CoolRunGame extends Game {
    // 用于屏幕自适应的长宽
    public static final int VIEW_WIDTH = 800;
    public static final int VIEW_HEIGHT = 480;
    public static final float PPM = 256;
    public Stage stage;
    public BitmapFont bitmapFont;
    public SpriteBatch batch;
    public OrthographicCamera camera;
    // 画面自适应
    public Viewport viewport;

    @Override
    public void create() {
        batch = new SpriteBatch();
        camera = new OrthographicCamera();
        viewport = new FitViewport(CoolRunGame.VIEW_WIDTH, CoolRunGame.VIEW_HEIGHT, camera);
        stage = new Stage(viewport, batch);
        bitmapFont = new BitmapFont();
        setScreen(new WelcomeScreen(this));
    }

    @Override
    public void dispose() {
        batch.dispose();
        stage.dispose();
        bitmapFont.dispose();
    }
}
